home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6394 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: news.mistral.co.uk!usenet
  2. From: mikebarnard@mistral.co.uk (Mike Barnard)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Do you have ever pass structures?
  5. Date: Sat, 24 Feb 1996 16:19:36 GMT
  6. Organization: Mistral Internet (Brighton)
  7. Message-ID: <4gnlf2$1fh@news.mistral.co.uk>
  8. References: <4ge8mi$qjm@srvr1.engin.umich.edu>
  9. NNTP-Posting-Host: 194.73.212.177
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. Hi.
  13.  
  14. hasdi@news-server.engin.umich.edu (HASDI RODZMANN HASHIM) wrote:
  15.  
  16. >MY QUESTION is do you ever pass the whole structures to a function
  17. >or you just pass a pointer to a function? For example, for a struct
  18. >of the following size...
  19.  
  20. I'm new at this and not very good. But I have been reading on this
  21. subject ant it seems that if you pass the whole structure it takes a
  22. lot longer at the whole structure is copied onto the stack. If this is
  23. in a loop it could take up valuable code time. Also if you are for
  24. some reason close to the end of the stack you could overrun it and
  25. have a stack overflow error.
  26.  
  27. If you pass a pointer only the value of the pointer is put on the
  28. stack. Saves much time and stack space.
  29.  
  30. That seems to be the principle as I know it anyway. I repeat I'm new
  31. to this and there will probably be some details that are wrong.
  32.  
  33. I'm trying to set up a menu for the front of a program using
  34. structures to hold the information about each menu choice and an array
  35. of such structures to hold the entire menu. To quote from my teaching
  36. book...
  37.  
  38. "(Talking about pointers)...with this much fun who needs thier teeth
  39. drilled?"
  40.  
  41.  
  42. ---
  43. Mic.
  44. From windy and damp Worthing; England.
  45. mikebarnard@mistral.co.uk
  46.  
  47. (I just lost 4 fence panels to the wind here! The cost of
  48. replacing them could have bought me a new windows compiler!)
  49.  
  50.